package com.networkmanagerj.view.localFisico
{
	import com.networkmanagerj.model.LocalFisico;
	
	import mx.core.UIComponent;
	import mx.events.FlexEvent;

	public class LocalFisicoGridScript extends LocalFisicoGridView
	{
		public function LocalFisicoGridScript()
		{
			super();
			MESSAGE_SAVE_SUCESS = "Local salvo com sucesso!";
			MESSAGE_UPDATE_SUCESS = "Local alterado com sucesso!";
		}
		
		override protected function onCreateComplete(event:FlexEvent):void{
			super.onCreateComplete(event);	
		}

		override protected function loadDataProvider():void{
			dataProvider=null;
			remoteObject.getAll(LocalFisico.remoteClass);
		}
		
		override protected function gridEdit(object : Object):void
		{
			super.gridEdit(object);
			local = object as LocalFisico;
			tw.title = "Editando Local";
		}
		
		override protected function clearForm(child:UIComponent=null):void{
			local = new LocalFisico();
			tw.title = "Novo Local";
		}
		
		override protected function save():void{
			local.endereco = txtEndereco.text;
			local.nome = txtNome.text;
			if(local.id==0){
				remoteObject.save(local);
			}else{
				remoteObject.update(local);
			}
		}
	}
}